package model

import (
	"encoding/json"

	"github.com/pkg/errors"
)

// Marshal marshals Object
func (o *Object) Marshal() (string, error) {
	data, err := json.Marshal(o)
	if err != nil {
		return "", errors.Wrap(err, "Object Marshal")
	}
	return string(data), nil
}

// Unmarshal unmarshals object
func (o *Object) Unmarshal(data string) error {
	err := json.Unmarshal([]byte(data), o)
	if err != nil {
		return errors.Wrap(err, "Object Unmarshal")
	}
	return nil
}
